package homework01;
import java.util.Scanner;
public class homework5 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] name = new String[3];
        int[] quantity = new int[3];
        double[] price = new double[3];
        for (int i = 0; i < price.length; i++) {
            System.out.println("请录入第" + (i + 1) + "件商品的名称：");
            name[i] = scan.next();
            System.out.println("请录入第" + (i + 1) + "件商品的数量：");
            quantity[i] = scan.nextInt();
            System.out.println("请录入第" + (i + 1) + "件商品的单价：");
            price[i] = scan.nextDouble();
            System.out.println("第" + (i + 1) + "件商品录入成功!");
        }
        System.out.println("***欢迎来到旺旺超市***");
        System.out.println("--------------------------");
        System.out.println("商品名称       数量        单价         金额");
        double[] total = new double[3];
        for (int i = 0; i < total.length; i++) {
            total[i] = quantity[i] * price[i];
            System.out.println(name[i] + "       " + quantity[i] + "       " + price[i] + "       " + total[i]);
        }
        System.out.println("--------------------------");
        int totalQuantity = 0;
        double totalAmount = 0.0;
        for (int i = 0; i < quantity.length; i++) {
        totalQuantity+=quantity[i];
        totalAmount += total[i];
        }

        System.out.println("总数量：" + totalQuantity);
        System.out.println("总金额：" + totalAmount);

        double discountAmount = totalQuantity > 10 || totalAmount > 100 ? totalAmount * 0.5 : totalAmount;
        System.out.println("已优惠金额：" + (totalAmount - discountAmount));
        System.out.println("实付金额：" + discountAmount);
    }
}
